home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Chat & Communication
/
Digsby build 37
/
digsby_setup.exe
/
lib
/
dns
/
rdata.pyo
(
.txt
)
< prev
next >
Wrap
Python Compiled Bytecode
|
2008-10-13
|
9KB
|
302 lines
# Source Generated with Decompyle++
# File: in.pyo (Python 2.5)
import dns.exception as dns
import dns.rdataclass as dns
import dns.rdatatype as dns
import dns.tokenizer as dns
_hex_chunksize = 32
def _hexify(data, chunksize = None):
if chunksize is None:
chunksize = _hex_chunksize
hex = data.encode('hex_codec')
l = len(hex)
if l > chunksize:
chunks = []
i = 0
while i < l:
chunks.append(hex[i:i + chunksize])
i += chunksize
hex = ' '.join(chunks)
return hex
_base64_chunksize = 32
def _base64ify(data, chunksize = None):
if chunksize is None:
chunksize = _base64_chunksize
b64 = data.encode('base64_codec')
b64 = b64.replace('\n', '')
l = len(b64)
if l > chunksize:
chunks = []
i = 0
while i < l:
chunks.append(b64[i:i + chunksize])
i += chunksize
b64 = ' '.join(chunks)
return b64
__escaped = {
'"': True,
'\\': True }
def _escapify(qstring):
text = ''
for c in qstring:
if c in __escaped:
text += '\\' + c
continue
if ord(c) >= 32 and ord(c) < 127:
text += c
continue
text += '\\%03d' % ord(c)
return text
def _truncate_bitmap(what):
for i in xrange(len(what) - 1, -1, -1):
if what[i] != '\x00':
break
continue
return ''.join(what[0:i + 1])
class Rdata(object):
__slots__ = [
'rdclass',
'rdtype']
def __init__(self, rdclass, rdtype):
self.rdclass = rdclass
self.rdtype = rdtype
def covers(self):
return dns.rdatatype.NONE
def extended_rdatatype(self):
return self.covers() << 16 | self.rdtype
def to_text(self, origin = None, relativize = True, **kw):
raise NotImplementedError
def to_wire(self, file, compress = None, origin = None):
raise NotImplementedError
def validate(self):
dns.rdata.from_text(self.rdclass, self.rdtype, self.to_text())
def __repr__(self):
covers = self.covers()
if covers == dns.rdatatype.NONE:
ctext = ''
else:
ctext = '(' + dns.rdatatype.to_text(covers) + ')'
return '<DNS ' + dns.rdataclass.to_text(self.rdclass) + ' ' + dns.rdatatype.to_text(self.rdtype) + ctext + ' rdata: ' + str(self) + '>'
def __str__(self):
return self.to_text()
def _cmp(self, other):
raise NotImplementedError
def __eq__(self, other):
if not isinstance(other, Rdata):
return False
if self.rdclass != other.rdclass or self.rdtype != other.rdtype:
return False
return self._cmp(other) == 0
def __ne__(self, other):
if not isinstance(other, Rdata):
return True
if self.rdclass != other.rdclass or self.rdtype != other.rdtype:
return True
return self._cmp(other) != 0
def __lt__(self, other):
if not isinstance(other, Rdata) and self.rdclass != other.rdclass or self.rdtype != other.rdtype:
return NotImplemented
return self._cmp(other) < 0
def __le__(self, other):
if not isinstance(other, Rdata) and self.rdclass != other.rdclass or self.rdtype != other.rdtype:
return NotImplemented
return self._cmp(other) <= 0
def __ge__(self, other):
if not isinstance(other, Rdata) and self.rdclass != other.rdclass or self.rdtype != other.rdtype:
return NotImplemented
return self._cmp(other) >= 0
def __gt__(self, other):
if not isinstance(other, Rdata) and self.rdclass != other.rdclass or self.rdtype != other.rdtype:
return NotImplemented
return self._cmp(other) > 0
def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
raise NotImplementedError
from_text = classmethod(from_text)
def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
raise NotImplementedError
from_wire = classmethod(from_wire)
def choose_relativity(self, origin = None, relativize = True):
pass
class GenericRdata(Rdata):
__slots__ = [
'data']
def __init__(self, rdclass, rdtype, data):
super(GenericRdata, self).__init__(rdclass, rdtype)
self.data = data
def to_text(self, origin = None, relativize = True, **kw):
return '\\# %d ' % len(self.data) + _hexify(self.data)
def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
if tok.get_string() != '\\#':
raise dns.exception.SyntaxError, 'generic rdata does not start with \\#'
length = tok.get_int()
chunks = []
while None:
(ttype, value) = tok.get()
if ttype == dns.tokenizer.EOL or ttype == dns.tokenizer.EOF:
break
continue
hex = ''.join(chunks)
data = hex.decode('hex_codec')
if len(data) != length:
raise dns.exception.SyntaxError, 'generic rdata hex data has wrong length'
return cls(rdclass, rdtype, data)
from_text = classmethod(from_text)
def to_wire(self, file, compress = None, origin = None):
file.write(self.data)
def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
return cls(rdclass, rdtype, wire[current:current + rdlen])
from_wire = classmethod(from_wire)
def _cmp(self, other):
return cmp(self.data, other.data)
_rdata_modules = { }
_module_prefix = 'dns.rdtypes'
def get_rdata_class(rdclass, rdtype):
def import_module(name):
mod = __import__(name)
components = name.split('.')
for comp in components[1:]:
mod = getattr(mod, comp)
return mod
mod = _rdata_modules.get((rdclass, rdtype))
rdclass_text = dns.rdataclass.to_text(rdclass)
rdtype_text = dns.rdatatype.to_text(rdtype)
rdtype_text = rdtype_text.replace('-', '_')
if not mod:
mod = _rdata_modules.get((dns.rdatatype.ANY, rdtype))
if not mod:
try:
mod = import_module('.'.join([
_module_prefix,
rdclass_text,
rdtype_text]))
_rdata_modules[(rdclass, rdtype)] = mod
except ImportError:
try:
mod = import_module('.'.join([
_module_prefix,
'ANY',
rdtype_text]))
_rdata_modules[(dns.rdataclass.ANY, rdtype)] = mod
except ImportError:
mod = None
except:
None<EXCEPTION MATCH>ImportError
None<EXCEPTION MATCH>ImportError
None<EXCEPTION MATCH>ImportError
if mod:
cls = getattr(mod, rdtype_text)
else:
cls = GenericRdata
return cls
def from_text(rdclass, rdtype, tok, origin = None, relativize = True):
if isinstance(tok, str):
tok = dns.tokenizer.Tokenizer(tok)
cls = get_rdata_class(rdclass, rdtype)
if cls != GenericRdata:
token = tok.get()
tok.unget(token)
if token[0] == dns.tokenizer.IDENTIFIER and token[1] == '\\#':
rdata = GenericRdata.from_text(rdclass, rdtype, tok, origin, relativize)
return from_wire(rdclass, rdtype, rdata.data, 0, len(rdata.data), origin)
return cls.from_text(rdclass, rdtype, tok, origin, relativize)
def from_wire(rdclass, rdtype, wire, current, rdlen, origin = None):
cls = get_rdata_class(rdclass, rdtype)
return cls.from_wire(rdclass, rdtype, wire, current, rdlen, origin)